.class public Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;
.super Ljava/lang/Object;
.source "DiskSpaceCalculator.java"


# instance fields
.field private mBytesPerSecond:J

.field private mBytesRemaining:J

.field private mFile:Ljava/io/File;

.field private mPollTime:J

.field private mStartBytesRemaining:J

.field private mStartTime:J


# direct methods
.method public constructor <init>()V
    .locals 2

    .prologue
    .line 23
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 14
    const/4 v0, 0x0

    iput-object v0, p0, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mFile:Ljava/io/File;

    .line 15
    const-wide/16 v0, -0x1

    iput-wide v0, p0, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mBytesPerSecond:J

    .line 24
    invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;

    move-result-object v0

    iput-object v0, p0, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mFile:Ljava/io/File;

    .line 25
    return-void
.end method


# virtual methods
.method public pollDiskSpace()J
    .locals 20

    .prologue
    .line 37
    new-instance v7, Landroid/os/StatFs;

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mFile:Ljava/io/File;

    move-object/from16 v16, v0

    invoke-virtual/range {v16 .. v16}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v16

    move-object v0, v7

    move-object/from16 v1, v16

    invoke-direct {v0, v1}, Landroid/os/StatFs;-><init>(Ljava/lang/String;)V

    .line 38
    .local v7, fs:Landroid/os/StatFs;
    invoke-virtual {v7}, Landroid/os/StatFs;->getAvailableBlocks()I

    move-result v16

    move/from16 v0, v16

    int-to-long v0, v0

    move-wide v8, v0

    .line 39
    .local v8, numBlocks:J
    invoke-virtual {v7}, Landroid/os/StatFs;->getBlockSize()I

    move-result v16

    move/from16 v0, v16

    int-to-long v0, v0

    move-wide v5, v0

    .line 40
    .local v5, blockSize:J
    mul-long v3, v8, v5

    .line 41
    .local v3, b:J
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v12

    .line 43
    .local v12, t:J
    move-object/from16 v0, p0

    iget-wide v0, v0, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mBytesRemaining:J

    move-wide/from16 v16, v0

    cmp-long v16, v3, v16

    if-nez v16, :cond_1

    .line 61
    :cond_0
    :goto_0
    return-wide v3

    .line 46
    :cond_1
    move-wide v0, v12

    move-object/from16 v2, p0

    iput-wide v0, v2, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mPollTime:J

    .line 47
    move-wide v0, v3

    move-object/from16 v2, p0

    iput-wide v0, v2, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mBytesRemaining:J

    .line 49
    move-object/from16 v0, p0

    iget-wide v0, v0, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mBytesRemaining:J

    move-wide/from16 v16, v0

    move-object/from16 v0, p0

    iget-wide v0, v0, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mStartBytesRemaining:J

    move-wide/from16 v18, v0

    cmp-long v16, v16, v18

    if-lez v16, :cond_2

    .line 51
    move-object/from16 v0, p0

    iget-wide v0, v0, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mBytesRemaining:J

    move-wide/from16 v16, v0

    move-wide/from16 v0, v16

    move-object/from16 v2, p0

    iput-wide v0, v2, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mStartBytesRemaining:J

    .line 52
    move-object/from16 v0, p0

    iget-wide v0, v0, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mPollTime:J

    move-wide/from16 v16, v0

    move-wide/from16 v0, v16

    move-object/from16 v2, p0

    iput-wide v0, v2, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mStartTime:J

    goto :goto_0

    .line 56
    :cond_2
    move-object/from16 v0, p0

    iget-wide v0, v0, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mStartBytesRemaining:J

    move-wide/from16 v16, v0

    move-object/from16 v0, p0

    iget-wide v0, v0, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mBytesRemaining:J

    move-wide/from16 v18, v0

    sub-long v10, v16, v18

    .line 57
    .local v10, size:J
    move-object/from16 v0, p0

    iget-wide v0, v0, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mPollTime:J

    move-wide/from16 v16, v0

    move-object/from16 v0, p0

    iget-wide v0, v0, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mStartTime:J

    move-wide/from16 v18, v0

    sub-long v16, v16, v18

    const-wide/16 v18, 0x3e8

    div-long v14, v16, v18

    .line 58
    .local v14, time:J
    const-wide/16 v16, 0x0

    cmp-long v16, v14, v16

    if-lez v16, :cond_0

    .line 59
    div-long v16, v10, v14

    move-wide/from16 v0, v16

    move-object/from16 v2, p0

    iput-wide v0, v2, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mBytesPerSecond:J

    goto :goto_0
.end method

.method public reset()V
    .locals 2

    .prologue
    const-wide/16 v0, -0x1

    .line 28
    iput-wide v0, p0, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mBytesPerSecond:J

    .line 29
    iput-wide v0, p0, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mBytesRemaining:J

    .line 30
    iput-wide v0, p0, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mStartBytesRemaining:J

    .line 31
    return-void
.end method

.method public timeRemaining()J
    .locals 10

    .prologue
    .line 65
    iget-wide v2, p0, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mBytesPerSecond:J

    const-wide/16 v4, 0x0

    cmp-long v2, v2, v4

    if-gtz v2, :cond_0

    .line 66
    const-wide/16 v2, -0x1

    .line 69
    :goto_0
    return-wide v2

    .line 68
    :cond_0
    iget-wide v2, p0, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mBytesRemaining:J

    iget-wide v4, p0, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mBytesPerSecond:J

    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v6

    iget-wide v8, p0, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mPollTime:J

    sub-long/2addr v6, v8

    mul-long/2addr v4, v6

    const-wide/16 v6, 0x3e8

    div-long/2addr v4, v6

    sub-long v0, v2, v4

    .line 69
    .local v0, bytes:J
    iget-wide v2, p0, Lcom/htc/android/footprints/utils/voice/DiskSpaceCalculator;->mBytesPerSecond:J

    div-long v2, v0, v2

    goto :goto_0
.end method
